package GUI;

/*
 * @author Rodrigo Uzcátegui
 * @author Mario Puglisi
 * @author Álvaro Garrido
 */

import javax.swing.JFrame;
import Lógica.*;

public class SalirDelSistema extends javax.swing.JFrame
{
    private JFrame ventanaPadre;

    public SalirDelSistema()
    {
        initComponents();
        inicializarMisComponentes();
    }

    private void inicializarMisComponentes()
    {
        ComponentesGUIFrame.componentesBásicos(this, true, false);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        JBAceptar = new org.edisoncor.gui.button.ButtonAction();
        JBCancelar = new org.edisoncor.gui.button.ButtonAction();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel1.setText("Estás seguro que deseas salir del sistema?");
        jLabel1.setName("jLabel1"); // NOI18N

        JBAceptar.setText("Aceptar");
        JBAceptar.setFont(new java.awt.Font("Tahoma", 1, 11));
        JBAceptar.setName("JBAceptar"); // NOI18N
        JBAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JBAceptarActionPerformed(evt);
            }
        });

        JBCancelar.setText("Cancelar");
        JBCancelar.setFont(new java.awt.Font("Tahoma", 1, 11));
        JBCancelar.setName("JBCancelar"); // NOI18N
        JBCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JBCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jLabel1)
                .addContainerGap(10, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(35, Short.MAX_VALUE)
                .addComponent(JBAceptar, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(47, 47, 47)
                .addComponent(JBCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(35, 35, 35))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(JBAceptar, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(JBCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        ComponentesGUIFrame.habilitarVentana(ventanaPadre, true, true);
    }//GEN-LAST:event_formWindowClosed

    private void JBAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JBAceptarActionPerformed
        System.exit(0);
    }//GEN-LAST:event_JBAceptarActionPerformed

    private void JBCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JBCancelarActionPerformed
        ComponentesGUIFrame.habilitarVentana(ventanaPadre, true, true);
        ComponentesGUIFrame.habilitarVentana(this, false, false);
    }//GEN-LAST:event_JBCancelarActionPerformed

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new SalirDelSistema().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.edisoncor.gui.button.ButtonAction JBAceptar;
    private org.edisoncor.gui.button.ButtonAction JBCancelar;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables

    public JFrame getVentanaPadre() {
        return ventanaPadre;
    }
    public void setVentanaPadre(JFrame ventanaPadre) {
        this.ventanaPadre = ventanaPadre;
    }
}
